function reallocObjectType(p,n)
  use derived,only:ObjectType
  implicit none

  type(ObjectType),pointer,dimension(:) :: reallocObjectType,p
  integer,intent(in) :: n
  integer :: ierr,i

  allocate(reallocObjectType(1:n),stat=ierr)
  if (ierr.ne.0) call abnormal_stop("reallocObjectType",&
       "Memory allocation causes an error.")

  if (.not.associated(p)) return

  do i=1,n-1
     reallocObjectType(i)%type_no=p(i)%type_no
     reallocObjectType(i)%name=p(i)%name
     ! reallocObjectType(i)%xmol_label=p(i)%xmol_label
  end do

  deallocate(p)

  return

end function reallocObjectType
